﻿<Window x:Class="UI.DesignWindow"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:system="clr-namespace:System;assembly=mscorlib"
	xmlns:cues="clr-namespace:Q2Q.Cues"
	xmlns:cueCon="clr-namespace:Q2Q.Cues.Converters"
	xmlns:cueHelp="clr-namespace:Q2Q.Cues.Helpers"
	xmlns:server="clr-namespace:Q2Q.Server"
	xmlns:controls="clr-namespace:Q2Q.Controls"
	xmlns:my="clr-namespace:Q2Q.UI"
	xmlns:base="clr-namespace:Q2Q"
	Title="{Binding ShowFile.DisplayName}" Height="700" Width="980" Icon="/Q2Q;component/Images/16x16/Logo.png" x:Name="ThisWindow" Style="{DynamicResource CustomWindowStyle}">
	<Window.CommandBindings>
		<CommandBinding Command="ApplicationCommands.Help" Executed="ExecuteHelp" />
		<CommandBinding Command="base:Commands.Settings" Executed="ExecuteSettings" />
		<CommandBinding Command="base:Commands.ToggleFullScreen" Executed="ExecuteFullScreen" />
		<CommandBinding Command="base:Commands.About" Executed="ExecuteAbout" />
		<CommandBinding Command="base:Commands.OpenRecentProject" Executed="ExecuteOpenRecentProject" />
		
		<CommandBinding Command="ApplicationCommands.New"   Executed="OnExecuteNewProject" CanExecute="CanExecute_NotInShowMode"/>
		<CommandBinding Command="ApplicationCommands.Open" Executed="OnExecuteOpenProject" CanExecute="CanExecute_NotInShowMode"/>
		<CommandBinding Command="ApplicationCommands.Close" Executed="OnExecuteExitApplication" CanExecute="CanExecute_NotInShowMode" />
		
		<CommandBinding Command="ApplicationCommands.Save" Executed="OnExecuteSaveProject" CanExecute="CanExecute_HasMinOneCue"/>
		<CommandBinding Command="ApplicationCommands.SaveAs" Executed="OnExecuteSaveAsProject" CanExecute="CanExecute_HasMinOneCue" />
		<CommandBinding Command="base:Commands.StopAllCues" Executed="ExecuteStopAllCues" CanExecute="CanExecute_HasMinOneCue" />
		<CommandBinding Command="base:Commands.ResetShow" Executed="ExecuteResetShow" CanExecute="CanExecute_HasMinOneCue" />
		<CommandBinding Command="base:Commands.CreateArchive" Executed="ExecuteCreateArchive" CanExecute="CanExecute_HasMinOneCue"/>
		
		<CommandBinding Command="base:Commands.Go" Executed="ExecuteGo" />
	</Window.CommandBindings>

	<Window.Resources>
		<Style TargetType="{x:Type GridSplitter}">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="GridSplitter">
						<Border x:Name="Border">
							<ContentPresenter />
						</Border>
						<ControlTemplate.Triggers>
							<Trigger Property="IsMouseOver" Value="True">
								<Setter TargetName="Border" Property="Background" Value="{StaticResource QOrange}" />
							</Trigger>
							<Trigger Property="IsMouseOver" Value="False">
								<Setter TargetName="Border" Property="Background" Value="{DynamicResource GridSplitter.Static.Background}" />
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>



		<cueHelp:CueTypeTemplateSelector x:Key="TypeSelect" />
	</Window.Resources>
	<Grid x:Name="TheGrid" Grid.IsSharedSizeScope="True">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="2*" MinHeight="300" />
			<RowDefinition Height="Auto" MaxHeight="600"/>
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="*" />
			<ColumnDefinition Width="Auto" />
		</Grid.ColumnDefinitions>
		
		
		<Menu x:Name="Menu" Grid.Row="0" Grid.ColumnSpan="2" Background="{x:Null}">
			<MenuItem Header="File">
				<MenuItem Header="New Project" Command="New" />
				<MenuItem Header="Open Project" Command="Open">
					<MenuItem.Icon>
						<Image Source="/Q2Q;component/Images/16x16/OpenFile.png" />
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem x:Name="RecentProjects" Header="Recent Projects" IsEnabled="{Binding IsNotInShowMode, ElementName=ThisWindow}">
				</MenuItem>
				<Separator />
				<MenuItem Header="Save Project" Command="Save">
					<MenuItem.Icon>
						<Image Source="/Q2Q;component/Images/16x16/Save.png" />
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Header="Save As" Command="SaveAs">
					<MenuItem.Icon>
						<Image Source="/Q2Q;component/Images/16x16/SaveAs.png" />
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Header="Create Archive" Command="base:Commands.CreateArchive">
				</MenuItem>
				<Separator />
				<MenuItem Header="Exit" Command="Close" />
			</MenuItem>
			<MenuItem Header="Edit">
				<MenuItem Header="Copy" Command="Copy" />
				<MenuItem Header="Paste" Command="Paste">
					<MenuItem.Icon>
						<Image Source="/Q2Q;component/Images/16x16/Paste.png" />
					</MenuItem.Icon>
				</MenuItem>
			</MenuItem>
			<MenuItem Header="Tools">
				<MenuItem Header="Remote Server" IsCheckable="True" IsChecked="{Binding IsServerRunning, ElementName=ThisWindow}" IsEnabled="{Binding RemoteEnabled, ElementName=ThisWindow}">
					<MenuItem.Icon>
						<Image Source="/Q2Q;component/Images/16x16/Remote.png" />
					</MenuItem.Icon>
				</MenuItem>
				<Separator />
				<MenuItem Header="Settings" Command="base:Commands.Settings">
					<MenuItem.Icon>
						<Image Source="/Q2Q;component/Images/16x16/Gears.png"/>
					</MenuItem.Icon>
				</MenuItem>
			</MenuItem>
			<MenuItem Header="Cues">
				<MenuItem Command="base:Commands.StopAllCues">
					<MenuItem.Icon>
						<Image Source="/Q2Q;component/Images/16x16/No.png" />
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Command="base:Commands.ResetShow">
					<MenuItem.Icon>
						<Image Source="/Q2Q;component/Images/16x16/Refresh.png" />
					</MenuItem.Icon>
				</MenuItem>
				<Separator />
				<MenuItem Header="Add Audio Cue" Command="base:Commands.AddAudioCue">
					<MenuItem.Icon>
						<Image Source="/Q2Q;component/Images/16x16/Sound.png" />
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Header="Bulk Add Audio Cues" Command="base:Commands.BulkAddAudioCues">
					<MenuItem.Icon>
						<Image Source="/Q2Q;component/Images/16x16/BulkAudio.png" />
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Header="Add Transport Cue" Command="base:Commands.AddTransportCue">
					<MenuItem.Icon>
						<Image Source="/Q2Q;component/Images/16x16/Stop.png" />
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Command="base:Commands.AddStackCue">
					<MenuItem.Icon>
						<Image Source="/Q2Q;component/Images/16x16/Stack.png" />
					</MenuItem.Icon>
				</MenuItem>
			</MenuItem>
			<MenuItem Header="View">
				<MenuItem Header="Fullscreen" Command="base:Commands.ToggleFullScreen" IsChecked="{Binding IsFullScreen, ElementName=ThisWindow}">
					<MenuItem.Icon>
						<Image Source="/Q2Q;component/Images/16x16/Fullscreen.png" />
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Header="Show Mode" IsCheckable="True" IsChecked="{Binding IsInShowMode, ElementName=ThisWindow}">
					<MenuItem.Icon>
						<Image Source="/Q2Q;component/Images/16x16/ShowMode.png" />
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Header="Playback Mixer Mode" IsCheckable="True" IsChecked="{Binding IsMixer, ElementName=ThisWindow}">

				</MenuItem>
				<Separator />
				<MenuItem Header="Console" IsCheckable="True" IsChecked="{Binding ShowConsole, ElementName=ThisWindow}">

				</MenuItem>
				<MenuItem Header="Go Button and Master Volume" IsCheckable="True" IsChecked="{Binding ShowGoAndVolume, ElementName=ThisWindow}">

				</MenuItem>
			</MenuItem>
			<MenuItem Header="Help">
				<MenuItem Header="View Help" Command="ApplicationCommands.Help">
					<MenuItem.Icon>
						<Image Source="/Q2Q;component/Images/16x16/Question.png" />
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Header="About" Command="base:Commands.About"/>
			</MenuItem>
		</Menu>

		<ListView Grid.Row="1" x:Name="MixerFaderView" Background="#FF4487B6" Visibility="{Binding IsMixer, ElementName=ThisWindow, Converter={StaticResource BooleanToVisibilityConverter}}">
			<ListView.Resources>
				<Style TargetType="{x:Type ListViewItem}">
					<Setter Property="VerticalContentAlignment" Value="Stretch" />
					<Setter Property="HorizontalAlignment" Value="Stretch" />
					<Setter Property="HorizontalContentAlignment" Value="Left" />
					<Setter Property="VerticalAlignment" Value="Stretch" />
					<Setter Property="FocusVisualStyle" Value="{x:Null}" />
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="ListViewItem">
								<Border Name="Border" Padding="8" SnapsToDevicePixels="True" BorderThickness="1" VerticalAlignment="Stretch">
									<Border.BorderBrush>
										<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
											<GradientStop Color="#FF9C9C9C" Offset="0"/>
											<GradientStop Color="#FF8F8F8F" Offset="1"/>
											<GradientStop Color="#FFADADAD" Offset="0.455"/>
										</LinearGradientBrush>
									</Border.BorderBrush>
									<Grid VerticalAlignment="Stretch">
										<Grid.RowDefinitions>
											<RowDefinition Height="*" />
											<RowDefinition Height="Auto" />
										</Grid.RowDefinitions>
										<controls:VolumeControl LabelText="{Binding Number}" Volume="{Binding Volume, Mode=TwoWay}" VerticalAlignment="Stretch"/>
										<StackPanel Grid.Row="1">
											<TextBlock Text="{Binding CurrentTime}" Background="Black" Foreground="#FF00FF23" FontFamily="Quartz MS" HorizontalAlignment="Stretch" TextAlignment="Center" />
											<TextBlock Text="{Binding Status}" Background="Black" Foreground="#FF00FF23" FontFamily="Quartz MS" HorizontalAlignment="Stretch" TextAlignment="Center" />
										</StackPanel>
									</Grid>
								</Border>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
			</ListView.Resources>
			<ListView.ItemsPanel>
				<ItemsPanelTemplate>
					<StackPanel Margin="20" Orientation="Horizontal" IsItemsHost="True"/>
				</ItemsPanelTemplate>
			</ListView.ItemsPanel>
		</ListView>

		<controls:CueList Grid.Row="1" x:Name="Cues" ParentCueNumber="0" IsEditingEnabled="{Binding IsNotInShowMode, ElementName=ThisWindow}" CueListing="{Binding ShowFile.CueList, Mode=TwoWay}" Grid.IsSharedSizeScope="True" Visibility="{Binding IsMixer, ElementName=ThisWindow, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=0}" />

		<Grid x:Name="ConsoleGrid" Grid.Row="2">
			<TextBox Height="0" Width="0"/> <!--Solves an issue with the first textbox control not getting styled properly.-->
			<TextBox x:Name="ConsoleText" VerticalAlignment="Stretch" MinHeight="60" Height="{Binding ActualHeight, ElementName=ConsoleGrid}" BorderThickness="0,1,0,0" Grid.Column="0" Text="{Binding Console.Contents}" TextWrapping="Wrap" IsReadOnly="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" FontSize="{Binding DefaultCueFontSize, ElementName=ThisWindow}" Visibility="{Binding ShowConsole, ElementName=ThisWindow, Converter={StaticResource BooleanToVisibilityConverter}}"/>
		</Grid>
		<GridSplitter Height="2" VerticalAlignment="Top" Grid.Row="2" HorizontalAlignment="Stretch" Visibility="{Binding ShowConsole, ElementName=ThisWindow, Converter={StaticResource BooleanToVisibilityConverter}}" />

		
		
		<Grid Grid.Row="1" Grid.RowSpan="2" Grid.Column="1" Visibility="{Binding ShowGoAndVolume, ElementName=ThisWindow, Converter={StaticResource BooleanToVisibilityConverter}}">
			<Grid.RowDefinitions>
				<RowDefinition Height="*" />
				<RowDefinition Height="Auto" />
			</Grid.RowDefinitions>
			<controls:VolumeControl Grid.Row="0" Margin="5,10" Volume="{Binding MasterVolume, ElementName=ThisWindow, Mode=TwoWay}" LabelText="Master Vol" FontSize="8" />
			<Button Grid.Row="1" Content="GO" Style="{StaticResource CustomButton2}" Command="base:Commands.Go" Width="80" Height="80" Background="#FF2AFF51" Focusable="False" IsTabStop="False" Margin="1" />

		</Grid>

		<StatusBar x:Name="StatBar" Grid.Row="3" Grid.ColumnSpan="2" Height="28">
			<StatusBar.Style>
				<Style TargetType="StatusBar">
					<Style.Triggers>
						<DataTrigger Binding="{Binding IsInShowMode, ElementName=ThisWindow}" Value="True">
							<Setter Property="Background" Value="{DynamicResource ShowMode}" />
						</DataTrigger>
						<DataTrigger Binding="{Binding IsInShowMode, ElementName=ThisWindow}" Value="False">
							<Setter Property="Background" Value="{x:Null}" />
						</DataTrigger>
					</Style.Triggers>
				</Style>
			</StatusBar.Style>
			<StatusBarItem Foreground="{DynamicResource TextForeground2}" Content="{Binding ShowFile.ActiveCueCount, Converter={StaticResource EmbeddedStringConverter}, ConverterParameter='~ Active Cues'}" />
		</StatusBar>
	</Grid>
</Window>